<?php
include_once("./common.inc.php");
$smarty = new Tpl();
$id = get_param("id");
$page = get_param("p");
$cid = get_param("cid");

$cat = load_model("category");
$art = load_model("article");

$id = intval($id);
if( empty($id) ) {
	echo 'error';
	exit;
	//$smarty->display('error.html');
}
$data['id'] = $id;
$children = $cat->get_children($id);
$cid = intval($cid);
if( empty($cid) ){
	$cid = $children[0]['id'];
}
$data['cid'] = $cid;
$children = tree($children,'  '); 
$smarty->assign('cats', $children);
//当前分类下的文章
$arts = $art->get_art("category=$cid");
$smarty->assign('arts', $arts);
//当前分类名称
$cat->free_result();
$tmpCat = $cat->get_cat($cid);
$data['cat_name'] = $tmpCat[0]['name'];
$smarty->assign($data);
//轮替图
$advModel = load_model("advertise");
$picList1 = $advModel->get_list();
$smarty->assign('picList1',$picList1);
//背景图
$arrBg = array(
		'bg_1'	=>'product_bg.gif',
		'bg_8'	=>'jie_top_bg.jpg',
		'bg_9'	=>'sever_top_img.jpg',
		'bg_10'	=>'support_top_bg.jpg',
		'bg_11'	=>'',
		'bg_12'	=>'pin_bg.gif'
		);
$smarty->assign('catBg',$arrBg['bg_'.$id]);
$smarty->display('category.html');
